package com.nuoniu.sibanyun.controller.erp;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.nuoniu.sibanyun.common.BaseController;
import com.nuoniu.sibanyun.common.result.HttpResult;
import com.nuoniu.sibanyun.entity.erp.ErpBankAccount;
import com.nuoniu.sibanyun.service.erp.IErpBankAccountService;
import com.nuoniu.sibanyun.userThread.UserInfo;
import com.nuoniu.sibanyun.userThread.UserThreadLocal;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 * 银行账户 前端控制器
 * </p>
 *
 * @author baiqiang
 * @since 2020-10-12
 */
@RestController
@RequestMapping("/erp/bankAccount")
@Api(tags = "银行账户管理")
public class ErpBankAccountController extends BaseController {

    @Autowired
    private IErpBankAccountService bankAccountService;

    @GetMapping("pageList")
    @ApiOperation("获取列表")
    public HttpResult pageList(Page page, ErpBankAccount bankAccount) {
        Page<ErpBankAccount> bankAccountPage = bankAccountService.pageList(page, bankAccount);
        return HttpResult.ok(bankAccountPage);
    }

    @PostMapping("save")
    @ApiOperation("保存")
    public HttpResult save(@RequestBody ErpBankAccount bankAccount) {
        bankAccountService.saveErpBankAccount(bankAccount);
        return HttpResult.ok();
    }

    @PostMapping("delete")
    @ApiOperation("删除")
    public HttpResult delete(@RequestBody List<Long> ids) {
        if(ids.size() > 0) {
            bankAccountService.deleteIds(ids);
        }
        return HttpResult.ok();
    }
}
